# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>

_realname=libunibreak
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=5.1
pkgrel=1
pkgdesc="An implementation of the line breaking algorithm as described in Unicode 5.2.0 Standard Annex 14, Revision 24 (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url='https://github.com/adah1972/libunibreak/'
license=('spdx:Zlib')
makedepends=("${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-cc")
source=("$_realname-$pkgver.tar.gz::https://github.com/adah1972/libunibreak/archive/libunibreak_${pkgver//./_}.tar.gz")
sha256sums=('d59878d82c84a60b592940a8e1a264f0a9714f0a9a8868b099846f780d9dc167')

prepare() {
  mv "${srcdir}/${_realname}-${_realname}_${pkgver//./_}" "${srcdir}/${_realname}-${pkgver}"
  cd "${srcdir}/${_realname}-${pkgver}"

  ./bootstrap
}

build() {
  cd "${srcdir}/${_realname}-${pkgver}"
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  ../"${_realname}-${pkgver}"/configure \
    --prefix="${MINGW_PREFIX}" \
    --build="${MINGW_CHOST}" \
    --host="${MINGW_CHOST}" \
    --target="${MINGW_CHOST}" \
    --enable-static \
    --enable-shared

  make
}

check() {
  cd "${srcdir}/build-${MSYSTEM}"

  make check
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  make install DESTDIR="${pkgdir}"

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/LICENCE" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENCE"
}
